package com.yuanshen.receive;

import com.yuanshen.pojo.Person;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @author 朱厚强
 * @version 1.0
 * @classname ObjectListener
 * 以对象的形式进行接收
 */
//@Component
public class ObjectListener {
    // 以对象的形式进行接收
    @RabbitListener(bindings = @QueueBinding(
            // 第一个值是队列相关的
            value = @Queue(name = "zhuhq.TOPIC.queue2"),
            // 第二个值是和交换机相关的
            exchange = @Exchange(name = "zhuhq.TOPIC",type = ExchangeTypes.TOPIC),
            // 第三个值是和key相关的 现在没有路由，所以先不管他。
            key = {"#.news",}
    ))
    public void receiveT3(Person person){
        System.out.println("receiveT2接收传递来的对象信息 = " + person);
    }
}
